x86: fix a few 32-on-64 compat mode issues
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 12 May 2008 09:15:07 +0000 (10:15 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 12 May 2008 09:15:07 +0000 (10:15 +0100)
- handle VCPUOP_register_vcpu_info and VCPUOP_get_physid (and add
  respective layout checks)
- add missing structure size check for struct vcpu_info
- add missing layout check for vcpu_set_periodic_timer
- handle VCPUOP_set_singleshot_timer via argument translation as the
  structure sizes differ (due to padding in 64-bits)

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen/arch/x86/x86_64/domain.c
xen/common/compat/domain.c
xen/include/xlat.lst
xen/tools/get-fields.sh

index 48cfec742391cd5e4beeffd432d8abab78288ba1..72cb58a2943eadfb5252a51ed16ff1f6cbab2e28 100644 (file)
@@ -9,11 +9,23 @@
 #include <asm/hypercall.h>
 #include <compat/vcpu.h>
 
+#define xen_vcpu_info vcpu_info
+CHECK_SIZE_(struct, vcpu_info);
+#undef xen_vcpu_info
+
+#define xen_vcpu_register_vcpu_info vcpu_register_vcpu_info
+CHECK_vcpu_register_vcpu_info;
+#undef xen_vcpu_register_vcpu_info
+
+#define xen_vcpu_get_physid vcpu_get_physid
+CHECK_vcpu_get_physid;
+#undef xen_vcpu_get_physid
+
 int
 arch_compat_vcpu_op(
     int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg)
 {
-    long rc = 0;
+    int rc = -ENOSYS;
 
     switch ( cmd )
     {
@@ -51,8 +63,9 @@ arch_compat_vcpu_op(
         break;
     }
 
-    default:
-        rc = -ENOSYS;
+    case VCPUOP_register_vcpu_info:
+    case VCPUOP_get_physid:
+        rc = arch_do_vcpu_op(cmd, v, arg);
         break;
     }
 
index 9e58cb145c49e4bd647663de9417c75982beb9c2..fa8e8d99076b6f7c6550c6bf2deb2ac7748b9c4b 100644 (file)
 #include <xen/hypercall.h>
 #include <compat/vcpu.h>
 
+#define xen_vcpu_set_periodic_timer vcpu_set_periodic_timer
+CHECK_vcpu_set_periodic_timer;
+#undef xen_vcpu_set_periodic_timer
+
 int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
 {
     struct domain *d = current->domain;
     struct vcpu *v;
-    long rc = 0;
+    int rc = 0;
 
     if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) )
         return -EINVAL;
@@ -57,7 +61,6 @@ int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
     case VCPUOP_is_up:
     case VCPUOP_set_periodic_timer:
     case VCPUOP_stop_periodic_timer:
-    case VCPUOP_set_singleshot_timer:
     case VCPUOP_stop_singleshot_timer:
     case VCPUOP_send_nmi:
         rc = do_vcpu_op(cmd, vcpuid, arg);
@@ -77,6 +80,19 @@ int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
         break;
     }
 
+    case VCPUOP_set_singleshot_timer:
+    {
+        struct compat_vcpu_set_singleshot_timer cmp;
+        struct vcpu_set_singleshot_timer *nat;
+
+        if ( copy_from_guest(&cmp, arg, 1) )
+            return -EFAULT;
+        nat = (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id);
+        XLAT_vcpu_set_singleshot_timer(nat, &cmp);
+        rc = do_vcpu_op(cmd, vcpuid, guest_handle_from_ptr(nat, void));
+        break;
+    }
+
     default:
         rc = arch_compat_vcpu_op(cmd, v, arg);
         break;
index 783c85249f0503beec01c26f7b32047422561b29..7b9a7ad9e18ca9727fab542effd84edb258fb8a2 100644 (file)
@@ -5,6 +5,7 @@
 ?      mmu_update                      xen.h
 !      mmuext_op                       xen.h
 !      start_info                      xen.h
+?      vcpu_info                       xen.h
 ?      vcpu_time_info                  xen.h
 !      cpu_user_regs                   arch-x86/xen-@arch@.h
 !      trap_info                       arch-x86/xen.h
 ?      sched_remote_shutdown           sched.h
 ?      sched_shutdown                  sched.h
 ?      t_buf                           trace.h
+?      vcpu_get_physid                 vcpu.h
+?      vcpu_register_vcpu_info         vcpu.h
 !      vcpu_runstate_info              vcpu.h
+?      vcpu_set_periodic_timer         vcpu.h
+!      vcpu_set_singleshot_timer       vcpu.h
 ?      xenoprof_init                   xenoprof.h
 ?      xenoprof_passive                xenoprof.h
 !      power_register                  platform.h
index cf81061e4b8890d771277bec44bb52eaec58b9a1..0a3885bea74128198ae3a4b4057914487c9df698 100644 (file)
@@ -310,7 +310,6 @@ build_body ()
        done
        echo " \\"
        echo "} while (0)"
-       echo ""
 }
 
 check_field ()